package com.itsxb.fallback;

import com.itsxb.constants.GlobalExceptionCode;
import com.itsxb.feign.LoginApi;
import com.itsxb.pojo.dto.LoginDto;
import com.itsxb.result.R;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class LoginApiFallbackFactory implements FallbackFactory<LoginApi> {
    @Override
    public LoginApi create(Throwable cause) {
        cause.printStackTrace();
        return new LoginApi() {
            @Override
            public R saveLogin(LoginDto loginDto) {
                return R.error(GlobalExceptionCode.SERVICE_ERROR);
            }
        };
    }
}
